package Form;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import Control.Workshop_ViewBooking_Controller;
import javax.swing.JSeparator;
import java.awt.Color;
import javax.swing.SwingConstants;

@SuppressWarnings("serial")
public class Workshop_ViewBooking_Form extends JPanel{
	//Object Attributes
	private Main parser;
	private Workshop_ViewBooking_Controller control;
	private JLabel lblViewAllBookings;
	private JLabel lblName;
	private JComboBox workshopCombo;
	private JScrollPane scrollPane;
	private JPanel viewPanel;
	private JPanel headerPanel;
	private JLabel lblTitle;
	private JSeparator separator;
	private JLabel lblStatus;
	private JSeparator separator_1;
	private JLabel lblStartDateTime;
	private JLabel lblBG;
	private JPanel titlePanel;
	
	public Main getParser() {
		return parser;
	}

	public void setParser(Main parser) {
		this.parser = parser;
	}

	public Workshop_ViewBooking_Controller getControl() {
		return control;
	}
	public void setControl(Workshop_ViewBooking_Controller control) {
		this.control = control;
	}
	public Workshop_ViewBooking_Form(Main parser) {
		this.setParser(parser);
		this.setControl(new Workshop_ViewBooking_Controller(this));
		
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[] {30, 220, 220, 30};
		gridBagLayout.rowHeights = new int[] {60, 40, 330, 30, 0, 0};
		gridBagLayout.columnWeights = new double[]{1.0, 0.0, 0.0, 1.0};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 1.0, 1.0, 1.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		GridBagConstraints gbc_titlePanel = new GridBagConstraints();
		gbc_titlePanel.gridwidth = 2;
		gbc_titlePanel.insets = new Insets(0, 0, 5, 5);
		gbc_titlePanel.fill = GridBagConstraints.BOTH;
		gbc_titlePanel.gridx = 1;
		gbc_titlePanel.gridy = 1;
		add(getTitlePanel(), gbc_titlePanel);
		GridBagConstraints gbc_scrollPane = new GridBagConstraints();
		gbc_scrollPane.gridwidth = 2;
		gbc_scrollPane.insets = new Insets(0, 0, 5, 5);
		gbc_scrollPane.fill = GridBagConstraints.BOTH;
		gbc_scrollPane.gridx = 1;
		gbc_scrollPane.gridy = 2;
		add(getScrollPane(), gbc_scrollPane);
		GridBagConstraints gbc_lblBG = new GridBagConstraints();
		gbc_lblBG.gridwidth = 4;
		gbc_lblBG.gridheight = 4;
		gbc_lblBG.insets = new Insets(0, 0, 5, 0);
		gbc_lblBG.gridx = 0;
		gbc_lblBG.gridy = 0;
		add(getLblBG(), gbc_lblBG);
	}

	public JLabel getLblViewAllBookings() {
		if (lblViewAllBookings == null) {
			lblViewAllBookings = new JLabel("View All Bookings For");
			lblViewAllBookings.setFont(new Font("Rockwell", Font.PLAIN, 20));
		}
		return lblViewAllBookings;
	}
	public JLabel getLblName() {
		if (lblName == null) {
			lblName = new JLabel("");
			lblName.setFont(new Font("Tahoma", Font.PLAIN, 18));
			lblName.setVisible(false);
		}
		return lblName;
	}
	public JComboBox getWorkshopCombo() {
		if (workshopCombo == null) {
			workshopCombo = new JComboBox();
			workshopCombo.setPreferredSize(new Dimension(180, 20));
			workshopCombo.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					control.generateWorkshopBookingList();
				}
			});
			workshopCombo.setVisible(false);
		}
		return workshopCombo;
	}
	public JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setPreferredSize(new Dimension(440, 330));
			scrollPane.setViewportView(getViewPanel());
			scrollPane.setColumnHeaderView(getHeaderPanel());
		}
		return scrollPane;
	}
	public JPanel getViewPanel() {
		if (viewPanel == null) {
			viewPanel = new JPanel();
		}
		return viewPanel;
	}
	public JPanel getHeaderPanel() {
		if (headerPanel == null) {
			headerPanel = new JPanel();
			headerPanel.setBackground(Color.BLACK);
			GridBagLayout gbl_headerPanel = new GridBagLayout();
			gbl_headerPanel.columnWidths = new int[]{180, 5, 75, 5, 150, 0};
			gbl_headerPanel.rowHeights = new int[]{25, 0};
			gbl_headerPanel.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
			gbl_headerPanel.rowWeights = new double[]{0.0, Double.MIN_VALUE};
			headerPanel.setLayout(gbl_headerPanel);
			GridBagConstraints gbc_lblTitle = new GridBagConstraints();
			gbc_lblTitle.insets = new Insets(0, 0, 0, 5);
			gbc_lblTitle.gridx = 0;
			gbc_lblTitle.gridy = 0;
			headerPanel.add(getLblTitle(), gbc_lblTitle);
			GridBagConstraints gbc_separator = new GridBagConstraints();
			gbc_separator.fill = GridBagConstraints.BOTH;
			gbc_separator.insets = new Insets(0, 0, 0, 5);
			gbc_separator.gridx = 1;
			gbc_separator.gridy = 0;
			headerPanel.add(getSeparator(), gbc_separator);
			GridBagConstraints gbc_lblStatus = new GridBagConstraints();
			gbc_lblStatus.insets = new Insets(0, 0, 0, 5);
			gbc_lblStatus.gridx = 2;
			gbc_lblStatus.gridy = 0;
			headerPanel.add(getLblStatus(), gbc_lblStatus);
			GridBagConstraints gbc_separator_1 = new GridBagConstraints();
			gbc_separator_1.fill = GridBagConstraints.BOTH;
			gbc_separator_1.insets = new Insets(0, 0, 0, 5);
			gbc_separator_1.gridx = 3;
			gbc_separator_1.gridy = 0;
			headerPanel.add(getSeparator_1(), gbc_separator_1);
			GridBagConstraints gbc_lblStartDateTime = new GridBagConstraints();
			gbc_lblStartDateTime.gridx = 4;
			gbc_lblStartDateTime.gridy = 0;
			headerPanel.add(getLblStartDateTime(), gbc_lblStartDateTime);
		}
		return headerPanel;
	}
	public JPanel getTitlePanel() {
		if (titlePanel == null) {
			titlePanel = new JPanel();
			titlePanel.add(getLblViewAllBookings());
			titlePanel.add(getLblName());
			titlePanel.add(getWorkshopCombo());
			FlowLayout layout = (FlowLayout)titlePanel.getLayout();
			layout.setAlignment(FlowLayout.LEFT);
		}
		return titlePanel;
	}
	public JLabel getLblTitle() {
		if (lblTitle == null) {
			lblTitle = new JLabel("");
			lblTitle.setForeground(Color.WHITE);
		}
		return lblTitle;
	}
	public JSeparator getSeparator() {
		if (separator == null) {
			separator = new JSeparator();
			separator.setOrientation(SwingConstants.VERTICAL);
			separator.setForeground(Color.WHITE);
		}
		return separator;
	}
	public JLabel getLblStatus() {
		if (lblStatus == null) {
			lblStatus = new JLabel("Status");
			lblStatus.setForeground(Color.WHITE);
		}
		return lblStatus;
	}
	public JSeparator getSeparator_1() {
		if (separator_1 == null) {
			separator_1 = new JSeparator();
			separator_1.setOrientation(SwingConstants.VERTICAL);
			separator_1.setForeground(Color.WHITE);
		}
		return separator_1;
	}
	public JLabel getLblStartDateTime() {
		if (lblStartDateTime == null) {
			lblStartDateTime = new JLabel("Start Date/Time");
			lblStartDateTime.setForeground(Color.WHITE);
		}
		return lblStartDateTime;
	}
	public JLabel getLblBG() {
		if (lblBG == null) {
			lblBG = new JLabel("");
			lblBG.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage("Resources/Images/Workshop/appointment.jpg").getScaledInstance(610, 640, Image.SCALE_DEFAULT)));
		}
		return lblBG;
	}
}
